//
//  RouterVO.m
//  Base
//
//  Created by liuwei7 on 2017/8/16.
//  Copyright © 2017年 com.yhd. All rights reserved.
//

#import "RouterVO.h"
#import "Router.h"

@implementation RouterVO

- (instancetype)init {
    if (self = [super init]) {
        self.createdType = PBRouteObjectCreateByCode;
        self.platformType = PBRoutePlatformTypeUniversal;
        self.animated = YES;
        self.isVirtual = NO;
    }

    return self;
}

- (UIViewController *)generateVCWithExtraData:(NSDictionary *)extraData {
    if (!self.className) {
        return nil;
    }

    Class class = NSClassFromString(self.className);
    if (!class) {
        return nil;
    }

    UIViewController *vc = nil;
    if (self.createdType == PBRouteObjectCreateByCode) {
        vc = [[class alloc] initWithNibName:nil bundle:nil];
    } else if (self.createdType == PBRouteObjectCreateByXib) {
        NSString *nibName = self.className;
        if ([nibName containsString:@"."]) {
            nibName = [nibName componentsSeparatedByString:@"."].lastObject;
        }
        vc = [[class alloc] initWithNibName:nibName bundle:[NSBundle mainBundle]];
    }

    return vc;
}


@end
